function padLeft(value: string, padding: string | number) {
  if (typeof padding === "number") {
    // 左边添加 padding 个空格
      return Array(padding + 1).join(" ") + value;
  }
  if (typeof padding === "string") {
      return padding + value;
  }
  throw new Error(`Expected string or number, got '${padding}'.`);
}

console.log(padLeft("abc", "abc"));
console.log(padLeft("abc", 8));